Fire watch callbacks on their own workqueue. Mainly this is
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 10 Oct 2005 15:57:41 +0000 (16:57 +0100)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Mon, 10 Oct 2005 15:57:41 +0000 (16:57 +0100)
to make debugging easier (it's hard if an error takes out
the default workqueue!). Also, watch callbacks can be
arbitrarily long-lived, so it's more polite.

Signed-off-by: Keir Fraser <keir@xensource.com>
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_xs.c

index 1b53fd73f5b5899f9d3e8e3ce47af1a7fd6bf03c..edf5f99af41b5d72acd148f39b4533f24ef221b5 100644 (file)
@@ -79,6 +79,7 @@ static struct xs_handle xs_state;
 
 static LIST_HEAD(watches);
 static DEFINE_SPINLOCK(watches_lock);
+static struct workqueue_struct *watches_workq;
 
 static int get_error(const char *errorstring)
 {
@@ -626,7 +627,7 @@ void unregister_xenbus_watch(struct xenbus_watch *watch)
        up_read(&xs_state.suspend_mutex);
 
        /* Make sure watch is not in use. */
-       flush_scheduled_work();
+       flush_workqueue(watches_workq);
 }
 EXPORT_SYMBOL(unregister_xenbus_watch);
 
@@ -708,7 +709,7 @@ static int process_msg(void)
                msg->u.watch.handle = find_watch(
                        msg->u.watch.vec[XS_WATCH_TOKEN]);
                if (msg->u.watch.handle != NULL) {
-                       schedule_work(&msg->u.watch.work);
+                       queue_work(watches_workq, &msg->u.watch.work);
                } else {
                        kfree(msg->u.watch.vec);
                        kfree(msg);
@@ -737,9 +738,6 @@ static int read_thread(void *unused)
        }
 }
 
-/*
-** Initialize the interface to xenstore. 
-*/
 int xs_init(void)
 {
        int err;
@@ -756,8 +754,12 @@ int xs_init(void)
        err = xb_init_comms();
        if (err)
                return err;
-       
-       reader = kthread_run(read_thread, NULL, "xenbusd");
+
+       /* Create our own workqueue for executing watch callbacks. */
+       watches_workq = create_singlethread_workqueue("xenwatch");
+       BUG_ON(watches_workq == NULL);
+
+       reader = kthread_run(read_thread, NULL, "xenbus");
        if (IS_ERR(reader))
                return PTR_ERR(reader);